import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { UserRole } from '@/modules/system/user-role/entities/user-role.entity';
import { RoleMenu } from '@/modules/system/role-menu/entities/role-menu.entity';
import { RoleApi } from '@/modules/system/role-api/entities/role-api.entity';
import { BaseTimeEntity } from '@/common/entities/base-time.entity';


@Entity({name:"yh_sys_role"})
export class Role extends BaseTimeEntity {
    @ApiProperty({ description: "id" })
    @PrimaryGeneratedColumn({ type: "bigint" })
    id: string;
    
    @ApiProperty({ description: "角色名称" })
    @Column({ type: "varchar", length: 100, comment: "角色名称" })
    name: string;
    
    @ApiProperty({ description: "角色备注" })
    @Column({ type: "varchar", length: 100, default: "", comment: "角色备注" })
    remark: string;
    
    @ApiProperty({ description: "角色排序" })
    @Column({ type: "int", default: 0, comment: "角色排序" })
    sort: number;
    
    @OneToMany(() => UserRole, (userRole) => userRole.role)
    userRole: UserRole[];
    
    @OneToMany(() => RoleMenu, (roleMenu) => roleMenu.role)
    roleMenu: RoleMenu[];
    
    @OneToMany(() => RoleApi, (roleApi) => roleApi.role)
    roleApi: RoleApi[];
    // @ManyToMany(() => Menus, (menus) => menus.role)
    // @Expose()
    // menus: Menus[];
}
